unit GLGUIShaders;

interface

uses
  GLSCene.Base.Context, dialogs,
  GLSCene.Utils,
  GLSCene.MaterialEx;

const
  ShadersPath = '..\GUI.Shaders\';
  quad_vp = ShadersPath + 'quad_vertex.glsl';
  quad_fp = ShadersPath + 'quad_fragment.glsl';
  quad_vp_120 = ShadersPath + 'quad_vertex_120.glsl';
  quad_fp_120 = ShadersPath + 'quad_fragment_120.glsl';
  text_vp_120 = ShadersPath + 'text_vertex_120.glsl';
  grad_fp_330 = ShadersPath + 'grad_fragment.glsl';
  HSL_fp_330  = ShadersPath + 'HSL_fragment.glsl';
  line_vp = ShadersPath + 'line_vertex.glsl';
  line_fp = ShadersPath + 'line_fragment.glsl';
type
  TGLGUIShaderNames = class
  private
    FReady: Boolean;
  public
    Vertex: String;
    Fragment: String;
    property Ready: Boolean read FReady default False;
  end;

function QuadShader: TGLGUIShaderNames;

implementation

var
  vQuadShader: TGLShaderEx;
  vQuadShaderNames: TGLGUIShaderNames;

function QuadShader: TGLGUIShaderNames;
begin
  if not Assigned(vQuadShaderNames) then
  begin
    vQuadShaderNames := TGLGUIShaderNames.Create;

    vQuadShader := GetInternalMaterialLibrary.AddShader(cInternalShader);
    vQuadShader.ShaderType := shtVertex;
    vQuadShader.SourceFile := quad_vp;
    vQuadShaderNames.Vertex := vQuadShader.Name;

    vQuadShader := GetInternalMaterialLibrary.AddShader(cInternalShader);
    vQuadShader.ShaderType := shtFragment;
    vQuadShader.SourceFile := quad_fp;
    vQuadShaderNames.Fragment := vQuadShader.Name;
    vQuadShaderNames.FReady := True;
  end;
  Result := vQuadShaderNames;
end;

initialization

finalization
if Assigned(vQuadShaderNames) then
  vQuadShaderNames.Free;
if Assigned(vQuadShader) then
  vQuadShader.Free;

end.

